#!/bin/bash
#author          :Ricardo de Souza Maia
#license         :GPLv3
#version         :$Id  
#encoding        :UTF-8
#Based on GNU/Linux CentOS /etc/init.d/httpd script

# httpd -f /etc/httpd-seplan/conf/httpd.conf -d /etc/httpd-seplan/
# start|restart|graceful|stop|graceful-stop
#httpd -f /etc/httpd-seplan/conf/httpd.conf -d /etc/httpd-seplan/ -t

$prog="httpd-$USERNAME"
$pidfile="/etc/httpd-$USERNAME/run/httpd.pid"

if [ -f /usr/sbin/httpd ]; then
     echo "Daemon httpd não encontrado."     
fi

case "$1" in
  start)
        echo -n $"Starting $prog: "
        httpd -f /etc/httpd-$USERNAME/conf/httpd.conf -d /etc/httpd-$USERNAME/
        ;;
  stop)
        echo -n $"Stopping $prog: "
        kill -9 $(<"/etc/httpd-$USERNAME/run/httpd.pid")
        rm /etc/httpd-$USERNAME/run/httpd.pid
        ;;
  status)
        status -p ${pidfile} $httpd
        RETVAL=$?
        ;;
  restart)
        httpd -f /etc/httpd-$USERNAME/conf/httpd.conf -d /etc/httpd-$USERNAME/ -k restart
        ;; 
  configtest)
       $apachectl $@
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $prog {start|restart|graceful|stop|graceful-stop|configtest|status}"
        RETVAL=2
esac

exit $RETVAL
  